<template>
  <div class="app-container">
    <el-form :model="formData" label-width="0px">
      <el-form-item>
        <el-form-item>网址删除</el-form-item>
        <el-select v-model="formData.inputType" placeholder="请选择输入类型">
          <el-option label="短网址" value="shortUrl" />
          <el-option label="后缀" value="suffix" />
        </el-select>
        <el-input
          v-model="formData.shortUrlInput"
          placeholder="请输入短网址(如:https://dwz.cn/xxx)或直接输入后缀(如:xxx)"
          style="width: 70%;"
        />
        <el-button
          type="primary"
          style="width: 15%;"
          @click="searchUrl"
        >搜索</el-button>
      </el-form-item>
    </el-form>
    <p style="color: #1989fa; margin-bottom: 15px;margin-left:140px;font-size: 10px;">
      短网址删除成功后,因服务缓存机制,短时间内依然可以访问,1小时内删除可完全生效。
    </p>
    <el-table :data="urlList" style="width: 100%;" border>
      <el-table-column align="center" label="创建时间" width="150">
        <template slot-scope="scope">
          {{ scope.row.createTime }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="短网址">
        <template slot-scope="scope">
          {{ scope.row.shortUrl }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="长网址">
        <template slot-scope="scope">
          {{ scope.row.longUrl }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="有效期" width="100">
        <template slot-scope="scope">
          {{ scope.row.expiry }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作">
        <template slot-scope="scope">
          <el-button
            type="danger"
            size="small"
            @click="deleteUrl(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
      <div v-if="urlList.length === 0" class="empty-data">
        <img src="path/to/empty-icon.png" alt="暂无数据" style="width: 60px; height: 60px; margin: 0 auto; display: block;">
        <p style="text-align: center; color: #999;">暂无数据</p>
      </div>
    </el-table>

  </div>
</template>

<script>
// import axios from 'axios'
// import path from 'path'
// import { deepClone } from '@/utils'
// import { getRoutes, getRoles, addRole, deleteRole, updateRole } from '@/api/role'

export default {
  data() {
    return {
      formData: {
        inputType: 'shortUrl',
        shortUrlInput: ''
      },
      urlList: []
    }
  }
  // methods: {
  //   async searchUrl() {
  //     try {
  //       const response = await axios.post('/search-url', {
  //         inputType: this.formData.inputType,
  //         shortUrlInput: this.formData.shortUrlInput
  //       })
  //       this.urlList = response.data
  //     } catch (error) {
  //       console.error(error)
  //     }
  //   }

  // }
}
</script>

<style lang="scss" scoped>
.app-container {
  size: 20px;
  max-width: 1000px;
  margin: 20px auto;
  padding: 30px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  .el-form-item {
    margin-bottom: 15px;
  }
  .el-input {
    width: 70%;
  }
  .el-button {
    width: 15%;
    &.primary {
      background-color: #409eff;
      border-color: #409eff;
      &:hover {
        background-color: #66b1ff;
        border-color: #66b1ff;
      }
    }
  }
  .el-select {
    width: 120px;
  }
  .empty-data {
    text-align: center;
    padding: 50px 0;
  }
}
</style>
